package com.nageoffer.shortlink.project.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.nageoffer.shortlink.project.dao.entity.LinkDO;
import com.nageoffer.shortlink.project.dto.req.ShortLinkCreateReqDto;
import com.nageoffer.shortlink.project.dto.req.ShortLinkPageReqDto;
import com.nageoffer.shortlink.project.dto.req.ShortLinkUpdateReqDto;
import com.nageoffer.shortlink.project.dto.resp.ShortLinkCountQueryRespDto;
import com.nageoffer.shortlink.project.dto.resp.ShortLinkCreateRespDto;
import com.nageoffer.shortlink.project.dto.resp.ShortLinkPageRespDto;
import jakarta.servlet.ServletRequest;
import jakarta.servlet.ServletResponse;

import java.io.IOException;
import java.util.List;

/**
 * 短链接接口层
 */
public interface ShortLinkService extends IService<LinkDO> {
    /**
     * 创建短链接
     * @param requestParam 创建短链接请求参数
     * @return 短链接创建信息
     */
    ShortLinkCreateRespDto createShortLink(ShortLinkCreateReqDto requestParam);

    /**
     * 短链接分页查询
     * @param requestParam 短链接分页查询请求参数
     * @return 短链接分页查询返回参数
     */
    IPage<ShortLinkPageRespDto>  pageShortLink(ShortLinkPageReqDto requestParam);

    /**
     * 查询短链接分组数量
     * @param requestParam
     * @return
     */
    List<ShortLinkCountQueryRespDto> listGroupShortLinkCount(List<String> requestParam);

    /**
     * 更新短链接
     * @param requestParam
     */
    void updateShortLink(ShortLinkUpdateReqDto requestParam);

    /**
     * 短链接跳转
     * @param shortUri 短链接后缀
     * @param request  HTTP请求
     * @param response HTTP响应
     */
    void restoreUrl(String shortUri, ServletRequest request, ServletResponse response) throws IOException;
}
